// 封装接口
import http from './axios';

// 获取带有树形结构的菜单列表
export const getTreeMenu = () => http('/menulist?istree=1')

// 新增菜单
export const addMenu = (data) => http.post('/menuadd', data)

// 删除菜单
export const delMenu = (id) => http.post('/menudelete', {id})

// 编辑菜单
export const editMenu = (data) => http.post('/menuedit', data)

// 获取角色列表
export const getRoleList = () => http('/rolelist')

// 新增角色
export const addRole = (data) => http.post('/roleadd', data)

// 修改角色
export const editRole = (data) => http.post('/roleedit', data)

// 删除角色
export const delRole = (id) => http.post('/roledelete', {id})

// 获取管理员总数
export const getTotalNum = () => http('/usercount')

// 获取管理员列表
export const getUserList = (data) => http('/userlist', {params: data})

// 新增管理员--这个账号可以用来登录后台管理系统
export const addUser = (data) => http.post('/useradd', data)

// 管理员登录--登录后台管理系统
export const userLogin = data => http.post('/userlogin', data)

// 获取分类列表(树形)
export const getCateListTree = () => http('/catelist?istree=1')

// 根据上级分类获取下级分类
export const getCateListByPid = (pid) => http('/catelist?pid='+pid)

// 新增商品分类
export const addCate = (data) => http.post('/cateadd', data)

// 修改商品分类
export const editCate = (data) => http.post('/cateedit', data)

// 获取商品规格列表
export const getSpecslist = (data) => http('/specslist?page=1&size=99')

// 新增商品规格
export const addSpecs = (data) => http.post('/specsadd', data)

// 获取商品总数
export const getTotalGoods = () => http('/goodscount')

// 获取商品列表
export const getGoodsList = (data) => http('/goodslist', {params: data})

// 修改商品
export const editGoods = (data) => http.post('/goodsedit', data)
